package com.wangzha.business.service;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;

import com.wangzha.common.base.service.BaseService;
import com.wangzha.common.kit.SqlKit;
import com.wangzha.common.model.UserRecordParam;
import com.wangzha.common.vo.Grid;

import java.util.List;

/**
 * 
 * @author qinhailin
 * @date 2021-04-06
 */
public class UserRecordParamService extends BaseService {
	private UserRecordParam dao = new UserRecordParam().dao();

    @Override
   public Model<UserRecordParam> getDao(){
    	return dao;
   }

   public Grid page(int pageNumber, int pageSize,Record record) {
      Record rd = new Record();
      //rd.set("user_name like", record.getStr("keyword"));
      return queryForList(pageNumber, pageSize,rd);
   }

   public UserRecordParam findUserRecordParam(String userCode, Long groupId, Long recordId) {
      return getDao().findFirst("select * from user_record_param where user_code = ? and group_id = ? and record_id = ?",
              userCode, groupId, recordId);
   }

   public List<UserRecordParam> findUserRecordParam(String userCode, Long groupId) {
      return getDao().find("select * from user_record_param where user_code = ? and group_id = ?", userCode, groupId);
   }

   public List<UserRecordParam> findUserRecordParam(String userCode, Long groupId, List<Long> recordIds) {
      return getDao().find("select * from user_record_param where user_code = ? and group_id = ? and record_id in " + SqlKit.joinId(recordIds), userCode, groupId);
   }

}
